import 'package:flutter/material.dart';
import 'package:flutter_easyrefresh/easy_refresh.dart';
import 'package:flutterhello/controller/Controller.dart';
import 'package:flutterhello/util/host_util.dart';
import 'package:flutterhello/widgets/tips_card.dart';
import 'package:get/get.dart';

class MyCreateTeamPage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    final controller = Get.put(Controller());
    return Scaffold(
      appBar: PreferredSize(
        child:
            AppBar(title: Text('我创建的团队'), centerTitle: true, actions: <Widget>[
          IconButton(
            icon: Icon(
              Icons.add,
              color: Colors.white,
            ),
            onPressed: () {
              Get.toNamed('/create_team'); // do something
            },
          ),
        ]),
        preferredSize: Size.fromHeight(50),
      ),
      body: EasyRefresh.custom(
        slivers: <Widget>[
          SliverList(
            delegate: SliverChildBuilderDelegate(
              (context, index) {
                return Padding(
                  padding: EdgeInsets.only(
                    left: 20,
                    right: 20,
                  ),
                  child: Column(
                    children: [
                      SizedBox(
                        height: 10,
                      ),
                      GestureDetector(
                        child: TipsCard(
                          favicon: HostUtil.getHost() +
                              controller.myCreateGroup[
                                  controller.myCreateGroup.length -
                                      index -
                                      1]['favicon'],
                          name: controller.myCreateGroup[
                                  controller.myCreateGroup.length - index - 1]
                              ['groupname'],
                        ),
                        onTap: () {
                          Get.toNamed('/team',
                              arguments: controller.myCreateGroup[
                                  controller.myCreateGroup.length - index - 1]);
                        },
                      ),
                    ],
                  ),
                );
              },
              childCount: controller.myCreateGroup.length,
            ),
          )
        ],
      ),
    );
  }
}
